<%@ Page Language="C#" EnableViewState="false" ValidateRequest="false" AutoEventWireup="true" 
	MasterPageFile="~/App_ThemeMasters/NoStyle/AdminOneColumnLayout.Master" Inherits="Syrinx.Gui.AspNet.Ajax.NitobiBasePage" %>

<%@ Register Assembly="Swaf.Gui.AspNet2" Namespace="Swaf.Gui.AspNet2" TagPrefix="swf" %>
<%@ Register Assembly="ScsAspNet" Namespace="Syrinx.Gui.AspNet.Ajax" TagPrefix="saj" %><%@ Register Assembly="NitobiControls" Namespace="Nitobi" TagPrefix="ntb" %>
<%@ Register Assembly="ScsAspNet" Namespace="Articles.Gui.AspNet" TagPrefix="art" %>
<%@ Register Assembly="UserManagement.Gui.AspNet" Namespace="UserManagement.Gui.AspNet" TagPrefix="usr" %>

<!--#include file="~/SiteControls/RegisterStandardControls.txt"-->
<!--#include file="../SiteControls/StandardAdminHeaderPageContent.inc"-->
<!--#include file="../SiteControls/StandardFooterPageContent.inc"-->
<script runat="server">
	public string TitleFormat = "$company.name$ - Security Management";
</script>

<asp:Content ID="c1" ContentPlaceHolderID="title" runat="server">
	<%SecurityPrivilege="AppFunctions.ManageCompanyConfiguration"; %>
    <h1 runat="server" ID="_compManagementlbl">Security Management</h1>
</asp:Content>

<asp:Content ID="c3" ContentPlaceHolderID="mainContent" runat="server">
	<swf:BizProc runat="server" ID="cmp" factoryName="company">
		<ParentBizProc id="loginBP" fieldName="companyId" dataId="id" />
	</swf:BizProc>
    <saj:Combo ID="companyGrid" runat="server"  Mode="Classic" GetDataUrl="NitobiLiveStreamHandler.aspx" ParentBizProcIds="cmp" DataTextField="keyName">
		<TextBox Width="250" />
		<List Width="370" Height="200" />
	    <Columns>
		    <ntb:BoundColumn DataField="id" Visible="false" />
		    <ntb:BoundColumn DataField="keyName" Visible="false" />
		    <ntb:BoundColumn DataField="depthName" HeaderText="Companies" width="300"  />
		    <ntb:BoundColumn DataField="enable" HeaderText="Enable" width="50"  />
	    </Columns>
    </saj:Combo>
    <ntb:TabStrip ID="tabs" runat="server" DelayLoad="true">
		<AutoSize FixedHeightMargin="325" FixedWidthMargin="75" />
		<TabItems>
			<ntb:TabItem Name="Company Settings" Width="150" NamedId="ta1" />
			<ntb:TabItem Name="User Groups" Width="150" NamedId="ta2" />
			<ntb:TabItem Name="Users" Width="150" NamedId="ta3" />
		</TabItems>
    </ntb:TabStrip>
    <div id="ta1" style="display:none;overflow:hidden;">
		<div>
    		<h3><asp:Label ID="_lmt" runat="server" >Company Limits</asp:Label></h3>
			<saj:NitobiBizObjDisplay ID="limitsDisplay" runat="server" 
				TemplateNameBizRule="getLimitsDisplayTemplate" ParentBizProcIds="cmp"  />
		</div>
		<div id="settings">
			<h3><asp:Label ID="companySettingsLbl" runat="server" >Company Settings</asp:Label></h3>
			<saj:NitobiBizObjDisplay ID="settingsDisplay" runat="server" 
				TemplateNameBizRule="getCompanySettingsDisplayTemplate"
				ParentBizProcIds="cmp" >
			</saj:NitobiBizObjDisplay>
		</div>
	</div>
	<div id="ta2" style="display:none">
	    <swf:BizProc runat="server" ID="ugrp" factoryName="userGroup">
		    <ParentBizProc id="cmp" fieldName="id" dataId="pid" />
	    </swf:BizProc>
		<span class="button1"><saj:ActionButton runat="server" ID="addBtn2" Actions="ugrp.AddBizObj" Text="Add" /></span>
		<span class="button6"><saj:ActionButton runat="server" ID="updateBtn2" Actions="ugrp.UpdateBizObj" Text="Update" /></span>
		<span class="button1"><saj:ActionButton runat="server" ID="cancelBtn2" Actions="ugrp.CancelEdits" Text="Cancel" /></span>
		<span class="button5"><saj:ActionButton runat="server" ID="deleteBtn2" Actions="ugrp.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
        <div class="clearer"></div>
        <table>
			<tr>
				<td valign="top">
					<saj:Grid ID="companyUserGroup" runat="server" ParentBizProcIds="ugrp"
						Width="330px" Height="200px" ShowToolbar="false" Mode="LiveScrolling" >
						<Columns>
							<ntb:KeyColumn DataField="id" />
							<ntb:BoundColumn DataField="name" HeaderText="Name" width="100" ReadOnly="false" />
							<ntb:BoundColumn DataField="description" HeaderText="Description" width="225" ReadOnly="false" />
						</Columns>
					</saj:Grid>
				</td>
				<td valign="top">
					<saj:NitobiBizObjDisplay ID="ugDisplay" runat="server" ParentBizProcIds="ugrp"
					EditableTemplate="UserManagement.Gui.AspNet.BasicUserGroupDisplay" />
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<swf:BizProc runat="server" ID="ugrpAF" FactoryName="userGroupAppFunctions">
						<ParentBizProc id="ugrp" dataId="userGroup" />
					</swf:BizProc>
					<div class="clearer" style="height:25px;"></div>
					<span class="button1"><saj:ActionButton runat="server" ID="bn5" Actions="ugrpAF.MasterDataOption" Text="Toggle All Security Options" /></span>
					<div class="clearer"></div>
					<saj:Grid ParentBizProcIds="ugrpAF" ID="ugAFGrid" runat="server" mode="LiveScrolling" Width="330px" Height="300px" ShowToolbar="false">
						<Columns>
								<ntb:KeyColumn DataField="id" />
								<ntb:BoundColumn DataField="description" HeaderText="Name" width="230"  />
								<ntb:ComboColumn DataField="privilege" HeaderText="Privilege" width="85" ValueField="id" DataSourceId="getPrivilegeLevels" GetDataUrl="/NitobiLiveStreamHandler.aspx">
									<ntb:BoundColumn DataField="id" Visible="false" />
									<ntb:BoundColumn DataField="name" />
								</ntb:ComboColumn>
						</Columns>	
					</saj:Grid>
				</td>
			</tr>
        </table>
	</div>
	
	<div id="ta3" style="display:none">
	    <swf:BizProc runat="server" ID="usr" factoryName="user">
		    <ParentBizProc id="cmp" fieldName="id" dataId="pid" />
	    </swf:BizProc>
		<span class="button1"><saj:ActionButton runat="server" ID="addBtn3" Actions="usr.AddBizObj" Text="Add" /></span>
		<span class="button6"><saj:ActionButton runat="server" ID="updateBtn3" Actions="usr.UpdateBizObj,uuGrp.UpdateBizObj" Text="Update" /></span>
		<span class="button1"><saj:ActionButton runat="server" ID="cancelBtn3" Actions="usr.CancelEdits" Text="Cancel" /></span>
		<span class="button5"><saj:ActionButton runat="server" ID="deleteBtn3" Actions="usr.DeleteBizObj" Text="Delete" ClientClick="if(!confirm('Are you sure you want to delete?'))return false;"/></span>
        <div class="clearer"></div>
        <saj:Grid ID="companyUsers" runat="server" ParentBizProcIds="usr"
            Width="330px" Height="200px" ShowToolbar="false" Mode="LiveScrolling">
            <Columns>
                <ntb:KeyColumn DataField="id" />
                <ntb:BoundColumn DataField="userName" HeaderText="Login Name" width="110" />
                <ntb:BoundColumn DataField="contact.fullName" HeaderText="Name" width="200" />
            </Columns>
        </saj:Grid>
	    <div class="clearer" style="height:25px"></div>
        <saj:NitobiBizObjDisplay ID="userDetail" runat="server" Width="100%" 
			EditableTemplate="UserManagement.Gui.AspNet.UserDisplay,Contacts.Gui.AspNet.BasicContactDisplay" ParentBizProcIds="usr" />
    <swf:BizProc id="uuGrp"	runat="server" FactoryName="userUserGroups">
		<ParentBizProc id="usr" fieldName="id" dataId="pid" />
		<ParentBizProc id="usr" fieldName="companyId" dataId="mlpid" />
    </swf:BizProc>
	<div class="clearer" style="height:5px;"></div>
	<span class="button1"><saj:ActionButton runat="server" ID="ab6" Actions="uuGrp.MasterDataOption" Text="Toggle All Security Options" /></span>
	<br /><br />
		<saj:ComplexBizObjListDisplay ID="usrUsrGroupsDisplay" runat="server" ParentBizProcIds="uuGrp"
			ReadOnlyTemplate="UserManagement.Gui.AspNet.UserUserGroupsListDisplay"  >
		</saj:ComplexBizObjListDisplay>		
    </div>    
    
 
</asp:Content>